﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProtocolConversion_WINCE
{
    class PowerPressure
    {
        public static Form1 form1 = new Form1();
        //外部供电电压//Date(10,2)
        private static short externalPowerPressure;
        //public short ExternalPowerPressure
        //{
        //    get { return externalPowerPressure; }
        //    set { externalPowerPressure = value; }
        //}
        public static void SegmentMessage(byte[] date, int length, string cmd)
        {
            //externalPowerPressure = Converter.BytesToUInt16(date, 10);

            byte[] returnFrameCMDByte = new byte[2];
            //查询CMD 字典
            if (Form1.ReturnFrameCMDByteDic.TryGetValue(cmd, out returnFrameCMDByte))
            {
                //检查校验字
                //if (Form1.CompareDate(Converter.TakeOutByteNoOrder(date, length - 2, 2), Form1.CalculateCheckByte(date)))
                {
                    //将数据填充到协议当中
                    if (Form1.FillDate(Converter.TakeOutByteNoOrder(date, 10, 2), 12, 2))
                    {
                        //form1.textBox4.Text += "电压值添加成功\t\n";

                    }
                    else
                    {
                        //form1.textBox4.Text += "电压值添加失败\t\n";
                    }
                }
                //else
                //{
                //    form1.textBox4.Text += "获取的电压值的校验字不匹配\t\n";
                //}
            }
            else
            {
                //form1.textBox4.Text += "未从字典中提取到电压命令对应的数据\t\n";
            }
        }
    }
}
